import platform
import os
from centos.re.re import resource_monitor
from centos.scan.scan import security_scan
from centos.process.process import process_manager
from centos.log.log import log_analyzer
from centos.user.user import user_manager

def clear_screen():
    """清屏，兼容Linux"""
    os.system('clear')

def print_menu():
    """显示主菜单，仅包含系统资源监控和安全漏洞扫描选项"""
    print("=" * 50)
    print("操作系统性能检测与分析工具（Linux版）")
    print("=" * 50)
    print("1. 系统资源监控（实时）")
    print("2. 安全漏洞扫描")
    print("3. 进程管理")
    print("4. 日志分析")
    print("5. 用户权限安全审查")
    print("0. 退出")
    print("=" * 50)
    choice = input("请输入选项 (0-5): ")
    return choice

def run_cli_mode():
    """CLI主循环"""
    if platform.system() != 'Linux':
        print("此程序专为Linux系统设计，请在Linux环境下运行")
        return
    while True:
        clear_screen()
        choice = print_menu()
        if choice == "1":
            resource_monitor()
        elif choice == "2":
            security_scan()
        elif choice == "3":
            process_manager()
        elif choice == "4":
            log_analyzer()
        elif choice == "5":
            user_manager()
        elif choice == "0":
            print("退出程序")
            break
        else:
            print("无效选项，请重试")
            input("\n按 Enter 继续...")

if __name__ == "__main__":
    run_cli_mode()